
local label = nil

local function slider_event_cb( e )

	local slider = lv.event_get_target( e );

	lv.label_set_text( label, string.format( "%d", lv.slider_get_value( slider ) ) );

	lv.obj_align_to( label, slider, lv.LV_ALIGN_OUT_TOP_MID, 0, -15 );
end

local slider = lv.slider_create( lv.scr_act() );

lv.obj_set_width( slider, 200 );

lv.obj_center( slider );

lv.obj_add_event_cb( slider, lv.LV_EVENT_VALUE_CHANGED, slider_event_cb );

label = lv.label_create( lv.scr_act() );

lv.label_set_text( label, "0" );

lv.obj_align_to( label, slider, lv.LV_ALIGN_OUT_TOP_MID, 0, -15 );
